﻿#region Copyright
// Partial Copyright (c) LogoUI Software Solutions LTD
// Author: Vladislav Spivak
// This source file is the part of LogoFX Framework http://logofx.codeplex.com
// See accompanying licences and credits.
#endregion

#if !SILVERLIGHT && !WinRT

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Interactivity;
using System.Windows;

namespace LogoFX.Infra.Interactivity.Actions
{
    public class TargetedOpenContextMenuAction : TargetedTriggerAction<object>
    {
        protected override void Invoke(object parameter)
        {
            FrameworkElement frameworkElement = Target as FrameworkElement;
            if (frameworkElement == null || frameworkElement.ContextMenu == null) return;

            frameworkElement.ContextMenu.DataContext = frameworkElement.DataContext;
            frameworkElement.ContextMenu.IsOpen = true;
        }
    }
}
#endif
